/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package org.abc;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.time.temporal.ChronoUnit;
import java.util.Locale;

/**
 * <p>Project: jse2303 - LocalDateDemo
 * <p>Powered by webrx On 2023-07-10 10:43:58
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class LocalDateDemo {
    public static void main(String[] args) {
        //格式化LocalDate
        LocalDate n = LocalDate.now();
        System.out.println(n.format(DateTimeFormatter.ofPattern("YYYY年MMMM月d日 E EEEE M MM MMM MMMM ", Locale.US)));
        System.out.println(n.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 EEEE MMMM")));

        LocalDate dok = LocalDate.parse("2008/05/12", DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        System.out.println(dok);
        System.out.printf("%tF %<tA%n", dok);


        System.exit(0);

        //只有年月日日期数据
        LocalDate now = LocalDate.now();


        System.out.println(now.isLeapYear());

        System.out.println(LocalDate.of(2000, 1, 1).isLeapYear());

        var dd5 = now.plus(-5, ChronoUnit.YEARS);
        System.out.println(dd5);


        var d2 = now.plusDays(5);
        System.out.println(d2);

        //var d3 = now.minusDays(7);
        var d3 = now.plusDays(-7);
        System.out.println(d3);

        var myd = LocalDate.of(2023, 5, 1);
        System.out.println(myd);
        System.out.printf("%tF %<tA%n", myd);
        System.out.printf("%tF %<tA %<tB%n", now);
        System.out.println("-----");

        DayOfWeek dw = myd.getDayOfWeek();
        System.out.println(dw.getValue());
        System.out.println(dw.getDisplayName(TextStyle.FULL, Locale.CHINA));
        System.out.println(dw.getDisplayName(TextStyle.FULL, Locale.US));
        System.out.println(dw.getDisplayName(TextStyle.SHORT, Locale.CHINA));
        System.out.println(dw.getDisplayName(TextStyle.SHORT, Locale.US));

        Month month = myd.getMonth();
        System.out.println(month.getDisplayName(TextStyle.FULL, Locale.CHINA));
        System.out.println(month.getDisplayName(TextStyle.SHORT, Locale.CHINA));
        System.out.println("-----");


        System.out.println(now);
        System.out.println(LocalDate.MIN);
        System.out.println(LocalDate.MAX);


    }
}
